// eslint-disable-next-line import/prefer-default-export
export const handleData = function (res, year) {
  const YEAR_STRING = year
  const experimentInfo = JSON.parse(res)
  let result = {}
  if (experimentInfo[YEAR_STRING]) {
    result = JSON.parse(experimentInfo[YEAR_STRING])
  }
  const score = result.defen
  result.charts = []
  result.charts.push(score.score_chengbeng)
  result.charts.push(score.score_xiaolu)
  result.charts.push(score.score_manyidu)
  result.charts.push(score.score_chengzhang)

  result.totalScore = 0
  // eslint-disable-next-line guard-for-in
  for(const i in result.charts) {
    result.totalScore += result.charts[i]
  }

  return result
}
